import java.io.File;
import java.io.IOException;

public class FileDemo03 {
    public static void main(String[] args) throws IOException {
        File file1 = new File("D:\\JavaLearn\\idea\\Code\\JavaSE_Code\\MyFile\\src\\tmp");
        file1.createNewFile();
        System.out.println(file1.getAbsolutePath());
        System.out.println(file1.getPath());
        System.out.println(file1.getName());
        System.out.println("--------");

        File file2 = new File("D:\\JavaLearn\\idea\\Code\\JavaSE_Code\\MyFile\\src\\tmp");
        String[] list = file2.list();
        for(String s : list)
            System.out.println(s);     //输出当前目录下所有的 文件和文件夹
        System.out.println("--------");

        File[] listFiles = file2.listFiles();
        for(File file : listFiles)
            if(file.isFile())
                System.out.println(file.getName());  //输出当前目录下所有文件

    }
}
